{extend name="user-layout" /}
{block name="content"}
<div class="content-wrapper">
    <div class="row">
        <div class="col-md-12 grid-margin stretch-card">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title">设置提现密码</h4>
                    <form class="layui-form forms-sample" action="" method="post">
                        <input name="p[uid]" value="{$user.uid}" hidden disabled readonly >
                        <div class="form-group row">
                            <label for="oldpassword" class="col-sm-2 col-form-label">登录密码</label>
                            <div class="col-sm-9">
                                <input type="password" name="p[oldpassword]" required lay-verify="required|oldpassword" value="" class="form-control" id="oldpassword" placeholder="登录密码">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="password" class="col-sm-2 col-form-label">提现密码</label>
                            <div class="col-sm-9">
                                <input type="password" name="p[password]" required lay-verify="required|password" value="" class="form-control" id="password" placeholder="提现密码">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="repassword" class="col-sm-2 col-form-label">重复提现密码</label>
                            <div class="col-sm-9">
                                <input type="password" name="p[repassword]" required lay-verify="required|repassword" value="" class="form-control" id="repassword" placeholder="重复提现密码">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label">手机验证码</label>
                            <div class="col-sm-9">
                                <div class="input-group col-xs-12">
                                    <input type="text" name="p[vercode]" required lay-verify="required" maxlength="6" class="form-control file-upload-info" placeholder="手机验证码">
                                    <span class="input-group-append">
                                        <button type="button" id="sendVerCode" class="file-upload-browse btn-show-vercode btn btn-primary">发送</button>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 col-form-label"></label>
                            <div class="col-sm-9">
                                <button type="button" class="btn btn-primary btn-submit-userpwd btn-fw" lay-submit lay-filter="app-user-submitpwd">提交修改</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="pagejs"}
<script src="__STATIC__/common/layui/layui.js"></script>
<script>
    layui.use(['form'], function(){
        let $ = layui.$
            ,form = layui.form
            , verBtn = $("#sendVerCode")
            , countdown = 60; // 验证码限制时间

        //数据验证
        form.verify({
            oldpassword: [/^[\S]{6,12}$/, "密码必须6到12位，且不能出现空格"],
            password: [/^[\S]{6,12}$/, "密码必须6到12位，且不能出现空格"],
            repassword: function(t) {
                if (t !== $("#password").val()) return "两次密码输入不一致"
            }
        });

        //监听搜索
        form.on('submit(app-user-submitpwd)', function(data){
            let field = data.field;
            console.log(field)
            //提交
            $.ajax({
                url:'{:url(\'index/User/cashpwd\')}',
                method:"POST",
                data:field, success:function (res) {
                    if (res.code == 1){setTimeout("location.reload();",1000);}
                    showToast(res);
                }
            });
        });
    });
</script>
{/block}
